﻿#region

using System;
using BTL.Technology.Data;

#endregion

namespace BTL.OnlineTestingSocial.Services.TestingEngine.Service.DAL
{
    public class CommentRepository : ICommentRepository
    {
        private readonly IDataHelper _dataHelper;
        private readonly DbSetting _dbSettings;

        public CommentRepository(DbSetting dbSettings, IDataHelper dataHelper)
        {
            _dbSettings = dbSettings;
            _dataHelper = dataHelper;
        }

        #region ICommentRepository Members

        /// <summary>
        /// insert comment
        /// </summary>
        /// <param name="content"></param>
        /// <param name="questionId"></param>
        /// <param name="questionGroupId"></param>
        /// <param name="createBy"></param>
        /// <returns></returns>
        public bool InsertComment(string content, int? questionDetailId, int? questionGroupId, string createBy)
        {
            try
            {
                _dataHelper.ExecuteNonQuery(_dbSettings.ConnectionString, _dbSettings.InsertCommentSp,
                    questionGroupId, questionDetailId, content, createBy);
            }
            catch (Exception)
            {
                return false;
            }
            return true;
        }

        #endregion
    }
}